Open
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces the new “Expressions2” package by adding several MISRA-related CodeQL queries, refactoring expression support modules, and updating test headers to mock standard library facilities. Key changes include:
- Addition of five new QLL queries enforcing MISRA rules RULE-8-1-2, RULE-8-1-1, RULE-8-0-1, and RULE-5-13-6.
- Refactoring of
Cpp14LiteralandExprmodules to support integer suffix parsing and temporary-object flow steps. - Introduction of the
Expressions2Packageand updates to exclusions and rule metadata for the new queries.
Reviewed Changes
Copilot reviewed 36 out of 36 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| cpp/misra/src/rules/RULE-8-1-2/ImplicitCapturesDisallowedInNonTransientLambda.ql | New query for explicit captures in non-transient lambdas |
| cpp/misra/src/rules/RULE-8-1-1/NonTransientLambdaImplicitlyCapturesThis.ql | New query preventing implicit this captures |
| cpp/misra/src/rules/RULE-8-0-1/MissingSizeofOperatorParenthesis.ql | New query enforcing parentheses around sizeof |
| cpp/misra/src/rules/RULE-8-0-1/MissingPrecedenceClarifyingParenthesis.ql | New query enforcing clarifying parentheses |
| cpp/misra/src/rules/RULE-5-13-6/LongLongLiteralWithSingleLSuffix.ql | New query disallowing single L suffix on long long literals |
| cpp/common/src/codingstandards/cpp/graph/GraphPathStateSearch.qll | Added stateful graph search module |
| cpp/common/src/codingstandards/cpp/Expr.qll | Refactored expression module; extracted temporaryObjectFlowStep |
| cpp/common/src/codingstandards/cpp/Cpp14Literal.qll | Added IntegerLiteralSuffix class and getSuffix() |
| cpp/common/src/codingstandards/cpp/Scope.qll | Added functionDefinedInTranslationUnit predicate |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/Expressions2.qll | New autogenerated exclusions for Expressions2 |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll | Imported Expressions2 in rule metadata |
| cpp/common/test/includes/standard-library/utility.h | Provided definitions for forward overloads |
| cpp/common/test/includes/standard-library/functional.h | Updated std::function mock constructor |
Comments suppressed due to low confidence (1)
cpp/common/test/includes/standard-library/utility.h:11
- The
movefunction is declared but not defined. Consider providing a definition like:
template <class T>
constexpr remove_reference_t<T>&& move(T&& t) noexcept {
return static_cast<remove_reference_t<T>&&>(t);
}template <class T> constexpr remove_reference_t<T> &&move(T &&t) noexcept;
cpp/common/src/codingstandards/cpp/graph/GraphPathStateSearch.qll
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
mbaluda
approved these changes
Feb 20, 2026
| bindingset[f, tu] | ||
| pragma[inline_late] | ||
| predicate functionDefinedInTranslationUnit(Function f, TranslationUnit tu) { | ||
| exists(FunctionDeclarationEntry fde | fde = f.getDefinition() | |
Collaborator
There was a problem hiding this comment.
Suggested change
| exists(FunctionDeclarationEntry fde | fde = f.getDefinition() | | |
| exists(FunctionDeclarationEntry fde | |
| [&]() { return l1; }(); // COMPLIANT | ||
| [l1]() { return l1; }(); // COMPLIANT | ||
| [&, l1]() { return l1; }(); // COMPLIANT | ||
| [&, l1]() { return l1 + l2; }(); // NON_COMPLIANT |
Collaborator
There was a problem hiding this comment.
Missing in the expected fille
Suggested change
| [&, l1]() { return l1 + l2; }(); // NON_COMPLIANT | |
| [&, l1]() { return l1 + l2; }(); // COMPLIANT |
| import codingstandards.cpp.misra | ||
| import codingstandards.cpp.AlertReporting | ||
|
|
||
| class MisraPrecedenceExpr instanceof Expr { |
Collaborator
There was a problem hiding this comment.
Can you document how the MISRA precedence differs from the standard Expr.getPrecedence()?
| } | ||
|
|
||
| // Test macros | ||
| #define UNSAFE_MACRO(x, y, z) x + y *z // NON_COMPLIANT macro definition |
Collaborator
There was a problem hiding this comment.
This alert is missing in the expected file
Suggested change
| #define UNSAFE_MACRO(x, y, z) x + y *z // NON_COMPLIANT macro definition | |
| #define UNSAFE_MACRO(x, y, z) x + y *z // NON_COMPLIANT[FALSE_NEGATIVE] macro definition |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
please enter the description of your change here
Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
RULE-8-0-1RULE-8-1-1RULE-8-1-2RULE-5-13-6RULE-18-9(no visible changes expected)Release change checklist
A change note (development_handbook.md#change-notes) is required for any pull request which modifies:
If you are only adding new rule queries, a change note is not required.
Author: Is a change note required?
🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.
Reviewer: Confirm that either a change note is not required or the change note is required and has been added.
Query development review checklist
For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:
Author
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
Reviewer
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.